package dashboard.util;

import java.security.MessageDigest;
import sun.misc.BASE64Encoder;

public class Crypto {	
	
	public static String encryptHash(String inputValue) throws Exception { // "MD5"
		if( inputValue == null ) 
			throw new Exception("Can't conver to MD5 String value!!");
			
		MessageDigest md = MessageDigest.getInstance("MD5"); 	//step 2
		
		byte raw[] = md.digest(inputValue.getBytes()); 			//step 4
		return new String((new BASE64Encoder()).encode(raw)); 	//step 5
		
	} 

	/* TEST */	
    public static void main(String args[]) throws Exception {    	       	
	System.out.println("Encode : " + Crypto.encryptHash(args[1]));	  
	     
    }

}
